package com.common.method;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import android.content.Context;

public class CommonMethod {
	public static boolean fileisExist(File file) {

		if (!file.exists()) {
			return false;
		}
		return true;

	}


	public static String readFile(String filename, Context context)
			throws IOException {

		FileInputStream inStream = context.openFileInput(filename);
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		int len = 0;
		byte[] buffer = new byte[1024];
		while ((len = inStream.read(buffer)) != -1) {
			outStream.write(buffer, 0, len);//
		}
		byte[] content_byte = outStream.toByteArray();
		String content = new String(content_byte);
		return content;
	}

	
	public static void writeSDFile(String fileName, String write_str,
			Context context) throws IOException {

		FileOutputStream outStream = context.openFileOutput(fileName,

		Context.MODE_PRIVATE);

		outStream.write(write_str.getBytes());

		outStream.close();
	}

	
}
